package com.trkj.service;


import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.trkj.dao.jpa.IjlalarmDAO;
import com.trkj.pojos.JlAlarmRegister;

@Service
@Transactional
public class JlalarmService {
	@Autowired
	private IjlalarmDAO alarmDAO;
	 /*
	 * 查看报警信息
	 */
	public Map<String, Object> queryalarmByPage(int page, int rows){
		PageRequest pr = new PageRequest(page - 1, rows);
		//获取当前页的记录
		List<JlAlarmRegister> list = alarmDAO.findalarmByPage(pr);
		//获取总的记录条数
		long total = alarmDAO.count();			
		Map<String, Object> map = new HashMap<>();
		map.put("total", total);
		map.put("rows", list);
		return map;
	}
	public void addalarm(JlAlarmRegister s){
		alarmDAO.save(s);
	     }
	//批量删除
	public void delregin(Long[] arId){
		for(int i=0;i<arId.length;i++){
			alarmDAO.delete(arId[i]);
		}				
    } 
	
	
	//根据地址查找
	public List<JlAlarmRegister> findbyhwy (String sex){
        BigDecimal bd=new BigDecimal(sex);
		List<JlAlarmRegister> list=alarmDAO.findbyhwy(bd);
		return list;
	}
	//根据身份证查找
	public List<JlAlarmRegister> findbybjrm(String sex){
		List<JlAlarmRegister> list=alarmDAO.findbybjrm(sex);
		return list;
	}
}
